package cn.xyafu.po;

public class Page {
    int start;          //开始索引（位置）
    int count;          //每页的数量
    int total;          //总的数据量

    public Page(int start, int count){
        super();
        this.start = start;
        this.count = count;
    }

    //判断是否有上一页
    public boolean isHasPreviouse(){
        if(start==1)
            return false;
        return true;
    }

    //判断是否有下一页
    public boolean isHasNext(){
        if(start==getTotalPage())
            return true;
        return false;
    }
    //计算得到总页数
    public int getTotalPage(){
        int totalPage;
        // 假设总数是50，是能够被5整除的，那么就有10页
        if (0 == total % count)
            totalPage = total /count;
            // 假设总数是51，不能够被5整除的，那么就有11页
        else
            totalPage = total / count + 1;

        if(0==totalPage)
            totalPage = 1;
        return totalPage;
    }

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }

    public int getCount() {
        return count;
    }

    public void setCount(int count) {
        this.count = count;
    }

    public int getTotal() {
        return total;
    }

    public void setTotal(int total) {
        this.total = total;
    }

    @Override
    public String toString() {
        return "Page{" +
                "start=" + start +
                ", count=" + count +
                ", total=" + total +
                '}';
    }
}
